package com.cqust.icc.task5.service.imp;


import com.cqust.icc.task5.domain.Customer;
import com.cqust.icc.task5.service.ICustomerServices;
import com.cqust.icc.task5.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;


public class CustomerServicesImp implements ICustomerServices {

    public Customer selectCustomerById(Long CustomerId) {

        SqlSession session = MyBatisUtils.getSession();

        return session.selectOne("CustomerMapper.selectCustomerById",CustomerId);
    }

    public List<Customer> selectCustomerList(Customer Customer) {
        SqlSession session = MyBatisUtils.getSession();

        return session.selectList("com.cqust.icc.task5.mapper.CustomerMapper.selectCustomerList",Customer);
    }

    public int insertCustomer(Customer Customer) {
        SqlSession session = MyBatisUtils.getSession();

        return session.insert("com.cqust.icc.task5.mapper.CustomerMapper.insertCustomer",Customer);
    }

    public int updateCustomer(Customer Customer) {
        SqlSession session = MyBatisUtils.getSession();

        return session.update("com.cqust.icc.task5.mapper.CustomerMapper.updateCustomer",Customer);
    }

    public int deleteCustomerById(Long CustomerId) {
        SqlSession session = MyBatisUtils.getSession();

        return session.delete("com.cqust.icc.task5.mapper.CustomerMapper.deleteCustomerById",CustomerId);
    }

}
